package com.springboot.java.design.lru;

/**
 * @Author: TongRui乀
 * @Date: 2020-09-01 15:12
 * @description：
 */
public class LruTest {

    public static void main(String[] args) {

        LruLinkedHashMap lru = new LruLinkedHashMap(5);

        lru.put("a", 1);
        lru.put("b", 2);
        lru.put("c", 3);

        System.out.println(lru.get("b"));

        print(lru);

        lru.put("d", 4);
        lru.put("e", 5);

        print(lru);

        System.out.println(lru.get("a"));

        print(lru);

        lru.put("f", 6);

        print(lru);
    }

    private static void print(LruLinkedHashMap lru){

        lru.forEach((k,v)->{
            System.out.println("key: " + k + "-- value: " + v);
        });

        System.out.println();

    }

}
